<?php

namespace app\api\validate;

use think\Validate;

class User extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'username'=> 'require|regex:^[A-Za-z0-9]{6,12}',
        'sitename'=> 'require|chs|length:2,10',
        'mobile'  => 'require|regex:^1\d{10}',
        'password'=> 'require|regex:^[A-Za-z0-9]{6,12}'
    ];
    /**
     * 提示消息
     */
    protected $message = [
        'username.require'  => '用户名不可为空',
        'username.regex'    => '用户名为6-12位数字或字符串',
        'sitename.require'  => '站点名称不可为空',
        'sitename.chs'      => '站点名称必须是汉字',
        'sitename.length'   => '站点名称需2-10字',
        'mobile.require'    => '手机号不可为空',
        'mobile.regex'      => '手机号不正确',
        'password.require'  => '密码不可为空',
        'password.regex'    => '密码为6-12位数字或字符串'
    ];
    /**
     * 验证场景
     */
    protected $scene = [
        'add'  => [],
        'edit' => [],
        'site_add' => ['username','sitename','mobile','password'],
        'user_add' => ['username','mobile','password']
    ];
    
}
